package com.controller.company;

import com.alibaba.fastjson.JSONObject;
import com.dao.JobDao;
import com.dao.imp.JobDaoimpl;
import com.entity.Vo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/CollectJob")
public class CollectJob extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        JobDao jobDao = new JobDaoimpl();
        List<Object> list = null;
        try {
//            list=jobDao.selectJobListById(req, resp);
            list=jobDao.collectJobListById(req, resp);
            if (list!=null){
                HttpSession session = req.getSession();
                session.setAttribute("jobs", list);
                System.out.print(list);
                resp.getWriter().write("success");
            }else {
                resp.getWriter().write("fail");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
